package hhm.android.machine

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import hhm.android.base.adapter.HBaseAdapter
import hhm.android.library.utils.GlideUtils
import hhm.android.library.utils.OnMultiClickListener
import siau.android.http.model.GetListTypeModel

class SelectMachineListAdapter(var context: Context, list: ArrayList<GetListTypeModel>, var listener: OnMultiClickListener) : HBaseAdapter<SelectMachineListViewHolder, GetListTypeModel>(list) {
    override fun bindData(holder: SelectMachineListViewHolder, bean: GetListTypeModel, position: Int) {
        holder.tv.text = bean.typeName
        GlideUtils.loadImage(
            context, bean.typeImg, holder.iv, when (bean.deviceType) {
                1 -> {
                    R.mipmap.weight_machine_bind
                }
                2 -> {
                    R.mipmap.height_machine_bind
                }
                3 -> {
                    R.mipmap.tooth_brush_machine_bind
                }
                else -> {
                    R.mipmap.no_data_bg
                }
            }, when (bean.deviceType) {
                1 -> {
                    R.mipmap.weight_machine_bind
                }
                2 -> {
                    R.mipmap.height_machine_bind
                }
                3 -> {
                    R.mipmap.tooth_brush_machine_bind
                }
                else -> {
                    R.mipmap.no_data_bg
                }
            }
        )
        holder.itemView.setOnClickListener(object : OnMultiClickListener() {
            override fun onMultiClick(v: View?) {
                v?.tag = bean
                listener.onMultiClick(v)
            }
        })
    }

    override fun bindView(parent: ViewGroup, viewType: Int): SelectMachineListViewHolder {
        val v = LayoutInflater.from(parent.context).inflate(R.layout.item_select_machine_list, parent, false)
        return SelectMachineListViewHolder(v)
    }
}